package com.strategy.example.demo.strategy;

import com.strategy.example.demo.service.ClothesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : spiderman
 * @version : 1.0
 * @FileName : com.strategy.example.demo.strategy
 * @Description :
 * @Create Date : 2021/12/6 23:20
 **/
@Component
public class StrategyService {

    Map<String, ClothesService> clothesServiceMap = new HashMap<>();

    public StrategyService(Map<String, ClothesService> map) {
        for (Map.Entry<String, ClothesService> entry : map.entrySet()) {
            clothesServiceMap.put(entry.getValue().serviceName(),
                    entry.getValue());
        }
    }

    public String getStrategy(String key) {
        return clothesServiceMap.get(key).printName();
    }


}
